import { request, BaseResponse } from '@/utils/request';
/**
 * @description 数据权限
 * @param {Namespace} isMock
 * @param isGetDataDirectly
 * @returns
 */

/**
 * 获取表格数据
 */

export function getDatalist(query: { id: string | number; type?: string }) {
  return request<BaseResponse<Array<Namespace.cateAccessList>>>(
    {
      url: `/sys/compermissions/getunitdata`,
      method: 'get',
      params: query,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

/**
 * 批量保存数据
 * @param data ID
 * @returns Array
 */

export function saveData(data: String) {
  return request<BaseResponse>(
    {
      url: `/sys/compermissions/batchsave`,
      method: 'post',
      data,
      headers: { 'Content-Type': 'application/json' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '提交成功',
    },
  );
}

/**
 * 批量删除数据
 * @param data ID
 * @returns Array
 */

export function deleteTableList(data: Array<number>) {
  return request<BaseResponse>(
    {
      url: `/sys/compermissions/batchremove`,
      method: 'post',
      data,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '删除成功',
    },
  );
}
